//这是ShopService的实现类，实现店铺的相关功能
package com.fer.service.impl;

import com.fer.mapper.ShopMapper;
import com.fer.model.Shop;
import com.fer.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class ShopServiceImpl implements ShopService {

    @Autowired
    private ShopMapper shopMapper;

    //查找全部店铺
    @Override
    public List<Shop> selectAllShop() {
        return shopMapper.selectAllShop();
    }

    //通过店铺的id查询店铺返回
    @Override
    public Shop selectShop(Integer boss_id) {
        return shopMapper.selectShop(boss_id);
    }

    //增加一个店铺信息
    @Override
    @Transactional(isolation = Isolation.READ_COMMITTED,propagation = Propagation.REQUIRED)
    public void insertShop(Shop shop) {
        shopMapper.insertShop(shop);
        //System.out.println(shop.getShop_id()+"添加成功");
    }

    @Override
    @Transactional(isolation = Isolation.READ_COMMITTED,propagation = Propagation.REQUIRED)
    public void deleteShop(Integer shop_id) {
        shopMapper.deleteShop(shop_id);
        System.out.println("删除成功");
    }

    @Override
    public boolean updateShop(Shop shop) {
        int result = shopMapper.updateShop(shop);
        if(result==-1){
            return false;
        }
        return true;
    }

}
